1. Field of the Invention
The present invention relates to an arithmetic operation circuit, and more specifically to an overflow correction circuit for use in an arithmetic operation circuit.
2. Description of Related Art
In the field of audio technique, hitherto, an audio signal is often converted into a digital signal, and then, the digital audio signal is subjected to an arithmetic operation. If an overflow occurs in a result of the arithmetic operation, it has been necessary to supply a maximum or minimum value of the digital number to an internal bus, since the overflowed data itself is no longer an appropriate audio data.
In brief, when the result of the arithmetic operation is outputted to the internal bus, the result of the arithmetic operation is stored in an accumulator having an overflow margin in comparison with a data length of the internal bus, so that even if an overflow occurs in the course of the arithmetic operation, the overflowed data is retained or returned to an arithmetic operation unit without the intermediary of the internal bus. With this arrangement, the arithmetic operation can be ensured to have the accuracy corresponding to a data width of a bus within the arithmetic operation unit. For example, if the internal data bus has a bus width of 20 bits, and if an overflow margin of 4 bits is ensured within the arithmetic operation unit so that the arithmetic operation unit has a bus width of 24 bits, the arithmetic operation can have the accuracy of 24 bits, and furthermore, the internal data bus can have the accuracy of 20 bits which is equal to the maximum data width of the internal data bus.
On the other hand, if the data width within the arithmetic operation is 20 bits, the bit length of data to be treated has to be reduced to 16 bits at an input of the arithmetic operation unit so that there does not occur an overflow in the course of the arithmetic operation. This will result in the fact that the arithmetic operation unit itself can have only the accuracy of 16 bits.
Furthermore, when a program to be used in the prior art arithmetic operation unit is prepared, the following method has been adopted:
(1) A program must be prepared so that the result of arithmetic operation will never overflow. Otherwise, a program must be prepared so that when the data overflowing into an overflow margin is outputted to the internal bus, a maximum or minimum data which can be expressed by the data width of the internal bus is outputted to the internal bus.
(2) A program must be prepared so that the overflow exceeding the overflow margin will never occur. Otherwise, a program is prepared so that when the overflow exceeding the overflow margin has occurred, a maximum or minimum data which can be expressed by the data width of the arithmetic operation unit (the data width of the internal bus+the overflow margin) is outputted to the accumulator.
In order to realize the above mentioned operation, the accumulator is required to have an overflow margin exceeding the data width of the internal bus, and there has been provided a flag indicative of whether or not the data overflows into the overflow margin. In this connection, the program is made such that when the data is stored in the accumulator, the overflow flag is set by a programmed operation, and when the data stored in the accumulator is outputted to the internal bus, the overflow flag is checked by a programmed operation so as to confirm whether or not the data to be outputted overflows into the overflow margin. If the data overflows into the overflow margin, the maximum or minimum value is set to the internal bus by a programmed operation. Furthermore, there have been required an instruction for discriminating whether or not the result of arithmetic operation overflows, and another instruction for setting correction data when the result of arithmetic operation overflows. These instructions will result in decrease of the operation speed of the arithmetic operation unit.
As mentioned hereinbefore, if the result of the arithmetic operation overflows to exceed the overflow margin, it becomes impossible to output an appropriate data as an audio data. Therefore, if the overflow correction is not made, the program must be made to ensure that the result of the arithmetic operation will never overflow to exceed the overflow margin.